Let a priced entry reverse a same-bar opposite market fill#96
Merged
Conversation
When two opposite strategy.entry calls fire on the same bar from flat — a market entry first, a priced (stop) entry second — the priced entry's fill previously took the close-only-opposite gate: it closed the market entry's position and was itself dropped, leaving the engine flat where TradingView holds the second entry's position. A clean-room probe (committed with its TV export) pins TV running no arbitration: both entries execute, and the second call's size covers its own quantity plus the pending same-bar opposite market quantity — which the ordinary full-reversal path reproduces exactly, since the closed position IS the market entry's quantity when placed from flat. Fix: a placement-time pending-order flag (priced entry created flat with an earlier same-bar opposite MARKET sibling) scopes the close-only-opposite gate out of market-first cells. Pending stop siblings do not set the flag (stop-vs-stop single-close preserved); placement-rejected entries never reach the queue; deferred-flip carries never match (created with a position open), so the gate's original semantics survive untouched. The probe's engine trade count converges to exactly TV's 7,429; the strategy that motivated the class is byte-identical (its dual bars ride the placement-rejection path). Out of pinned scope, characterization- frozen: stop-first cells that never ran in the probe, pyramiding>0, and TV's buy-first intra-open ordering (net position parity reproduced; trade decomposition of one cell differs, documented). Corpus 240/11/1 zero movement; full private sweep 0 up / 0 down. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two opposite
strategy.entrycalls on one bar from flat — market first, priced (stop) second — previously resolved with the priced entry's fill taking the close-only-opposite gate: it closed the market position and was dropped, engine flat where TV holds the second entry. A committed clean-room probe pins TV running no arbitration: both entries execute; the second call sizes own + pending same-bar opposite MARKET qty — exactly what the ordinary full-reversal path produces from flat.Fix: one placement-time flag (priced entry created flat with an earlier same-bar opposite MARKET sibling by creation order) scopes the close-only-opposite gate out of market-first cells. Stop siblings don't set it; placement-rejected entries never queue; deferred-flip carries never match — the gate's original semantics survive (deferred-flip suite green).
Gates (author + independent fresh-context R7, both green)
🤖 Generated with Claude Code